package com.bitbank.smartdevice.adapter.base

import android.content.Context


/**
 *  Date：2018/12/10
 *  Author：xulee
 *  Desc：
 */
abstract class CommonAdapter<T>(
    mContext: Context,
    protected var layoutId: Int,
    arrayData: Array<T>
) : MultiItemTypeAdapter<T>(mContext, arrayData) {

    val adapter: CommonAdapter<T>
        get() = this

    init {
        addItemViewDelegate(object : ItemViewDelegate<T> {
            override fun convert(holder: MViewHolder, t: T, position: Int) {
                adapter.convert(holder, t, position)
            }

            override val itemViewLayoutId: Int
                get() = layoutId

            override fun isForViewType(item: T, position: Int): Boolean {
                return true
            }
        })
    }

    protected abstract fun convert(holder: MViewHolder, t: T, position: Int)

}
